package java008;  
  
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;  
  
public class zy5 {  
	public static void main(String[] args) throws IOException {
        List<String> lines = new ArrayList<>();
        BufferedReader br = new BufferedReader(new FileReader("F:\\eclipse\\Java00801\\sort.txt"));
        String line;
        while((line = br.readLine()) != null) {
            lines.add(line);
        }
        br.close();

        Collections.sort(lines, new Comparator<String>() {

        	  @Override 
        	  public int compare(String o1, String o2) {

        	    String[] parts1 = o1.split("\\.");
        	    String[] parts2 = o2.split("\\.");

        	    int num1 = 0;
        	    int num2 = 0;

        	    if(parts1.length > 0 && !parts1[0].isEmpty()) {
        	      num1 = Integer.parseInt(parts1[0]);
        	    }

        	    if(parts2.length > 0 && !parts2[0].isEmpty()) {  
        	      num2 = Integer.parseInt(parts2[0]);
        	    }

        	    return num1 - num2;
        	  }

        	});

        BufferedWriter out = new BufferedWriter(new FileWriter("F:\\eclipse\\Java00801\\sort.txt"));

        for(String str : lines) {
            out.write(str);
            out.newLine();
        }
        out.close();
    }
}